#ifndef LLVMIR_H
#define LLVMIR_H

#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <resource.h>

namespace LLVMIR
{

    int get_type_size(const std::string &type);
    void add_llvm_code(const std::string &code);
    void print_llvm_code();
    void clear_llvm_code();
    // 生成一个{
    void add_left_brace();
    // 生成一个}
    void add_right_brace();
    void write_llvm_code_to_file(const std::string &file_name);
    void const_decl(std::string name, int value, int level, bool is_globle);
    void alloc_stack_space(std::string name, std::string type);
    void store(std::string name, std::string type, int value);
    void load(std::string name, std::string type, std::string result);
    void add(std::string type, std::string result, std::string op1, std::string op2);
    void sub(std::string type, std::string result, std::string op1, std::string op2);
    void mul(std::string type, std::string result, std::string op1, std::string op2);
    void div(std::string type, std::string result, std::string op1, std::string op2);
    void icmp(std::string type, std::string result, std::string op1, std::string op2);
    void br(std::string label);
    void define_function(std::string name);
    void define_main_function();
    // 常量数组声明
    void const_array_decl(std::string name, std::vector<int> values, int size, int level, bool is_globle);
    void var_decl(std::string name, int value, int level, bool is_globle);
    void var_decl_array(std::string name, std::vector<int> values, int size, int level, bool is_globle);
    void write(std::string name,bool is_globle);
    void read(std::string name);
    void call(std::string name);
    void insert_in_main(std::string code);
    void const_decl_array(std::string name, std::vector<int> values, int size, bool is_globle);
    void add_printf_and_scanf();
    void add_return_void();
    void add_icmp(std::string condition, std::string lhs, std::string rhs,std::string name);
    void add_if_true(std::string name);
    void add_if_false(std::string name);

}

#endif // LLVMIR_H